package com.lin.service.Impl;

import com.lin.mapper.AccountMapper;
import com.lin.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AccountServiceImpl implements AccountService {
    private AccountMapper accountMapper;
    @Autowired
    public void setAccountMapper(AccountMapper accountMapper) {
        this.accountMapper = accountMapper;
    }

    @Override
    @Transactional
    public void transfer(String from, String to, Integer money) {
        accountMapper.transferOut(from, to, money);
        // int i = 1/0; // 模拟业务错误
        accountMapper.transferIn(to, from, money);
    }
}
